#ifndef __CHANGE_MANAGER_H__
#define __CHANGE_MANAGER_H__

#include <cstdint>
#include <string>
#include <set>
#include <unordered_map>
#include <mutex>
#include <vector>
#include "Engine/Point3.hpp"
#include "SimpleSingleton.hpp"
#include "Game/WorldItem.hpp"
#include "GameLock.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    struct IInventory;
    class SubsystemTerrain;

    class ChangeManager : public SimpleSingletonItem
    {
        friend class SimpleSingleton;
    private:
        SpinLock m_inventoryChangeLock;
        std::map<uint32_t, std::set<int32_t>> m_inventoryChangeMap;

        SpinLock m_terrainChanageMutex;
        std::set<Point3> m_terrainChanageSet;

        SpinLock m_pickableCreativeMutex;
        std::vector<Pickable *> m_pickableCreativeVec;

        SubsystemTerrain *m_terrain;

    private:
        ChangeManager();
        ~ChangeManager();
        ChangeManager(const ChangeManager &) = delete;
        ChangeManager(ChangeManager &&) = delete;
        ChangeManager &operator=(const ChangeManager &) = delete;
        ChangeManager &operator=(ChangeManager &&) = delete;

    public:
        void loadGame();
        void update(float dt);
        void pickableCreative(Pickable *pickable);
        void inventoryChange(IInventory *inventory, int32_t slotIndex);
        void terrainChange(const Point3& point);
    };
} // namespace PocketSurvival


#endif
